<template>
  <div class="drawerComment">
    <el-drawer :visible="drawComment"
               :title="'评论数'+'('+total+')'"
               size="40%"
               :before-close="handleClose"
               ref="drawer">
      <!-- 评论列表 -->

      <div class="commentList"
           v-for="(item ,i) in commentData"
           :key="i">
        <img class="avaterImg"
             :src="item.user.avatar"
             alt="" />
        <div class="commentInfo">
          <div class="nickName">
            <span style="color: #000; font-weight: 400">{{ item.user.nickname}}</span>

          </div>
          <div class="rate">
            <el-rate v-model="value"
                     disabled
                     text-color="#ff9900"
                     score-template="{value}">
            </el-rate>
          </div>
          <div class="textComment"> {{ item.technicianEvaluation }} </div>

          <div class="commentTag">

            <el-tag v-for="(tag,i) in item.evaluationKeywords"
                    :key="i"
                    type="success"
                    icon="el-icon-delete">{{ tag }}</el-tag>

          </div>

          <div class="commentfooter">
            <div class="commentTime"> 2023-01-30 16:00 </div>
            <div class="deleted"> 删除 </div>
          </div>
        </div>
      </div>

    </el-drawer>
  </div>
</template>
  <script>
export default {
  name: 'drawerComment',
  props: {
    drawComment: {
      type: Boolean,
      default: false
    },
    data: {
      type: Object,
      default: () => { }
    }
  },
  components: {},

  data () {
    return {
      value: 5,
      commentData: null,
      total: null
    };
  },
  methods: {
    // 关闭抽屉
    handleClose () {
      console.log('评论');
      this.$emit('update:drawComment', false);
    }


  },
  watch: {
    drawComment (visible) {
      this.$nextTick(() => {
        if (visible) {

          if (this.data) {
            // 隐藏账号密码
            console.log(this.data)

            this.data.list.forEach((item) => {

              const imgStr = item.evaluationKeywords
              if (imgStr.length) {
                if (imgStr.includes(',')) {
                  console.log('字符串中包含逗号');
                  // 包含的进行slice(',') 分割
                  item.evaluationKeywords = imgStr.split(',').map((item) => item.trim());
                } else {
                  console.log('字符串中不包含逗号');
                  item.evaluationKeywords = imgStr.split();
                }


              }
            })
            console.log(this.data.list)
            this.commentData = this.data.list,
              console.log(this.commentData)
            this.total = this.data.count
          } else {

          }
        } else {

        }
      });
    }
  }
};
  </script>
  <style lang="less">
.drawerComment {
  .commentList {
    display: flex;
    padding: 14px 0;
    border-bottom: 1px solid #d9d9d9;
    margin: 0 20px;
    .avaterImg {
      width: 46px;
      height: 46px;
      border-radius: 46px;
      margin-right: 10px;
    }
    .commentInfo {
      width: 100%;
      .genderMask {
        width: 40px;
        height: 16px;
        background-color: #fd73a5;
        font-size: 12px;
        font-weight: 400;
        border-radius: 22px;
        display: inline-block;
        color: #fff;
        text-align: center;
        padding-right: 6px;
        line-height: 16px;
        margin-left: 10px;
        &::before {
          content: url('../../../../static/svg/girl.svg');
          display: inline-block;
          vertical-align: middle;
        }
      }
      .rate {
        margin: 5px 0;
      }

      .commentTime {
        color: #999;
        font-size: 13px;
        font-weight: 400;
      }
      .textComment {
        color: #000;
        margin: 10px 0;
        font-size: 14px;
        width: 85%;
      }
      .commentTag {
        margin: 8px 0;
      }
      .commentfooter {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .deleted {
          margin-left: 15px;
          &::before {
            content: url('../../../../static/svg/waste.svg');
            display: inline-block;
            vertical-align: middle;
          }
        }
      }
    }
  }
}
</style>
  